Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

That's the races out of our test suite! #5384

Merged
merged 45 commits into from
Jan 11, 2025

Conversation

andydotxyz
Copy link
Member

Working perfectly locally, let's see what CI says!

Progresses #4654

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

@andydotxyz
Copy link
Member Author

Oh man, so many races not detected on my local setup :(

@dweymouth
Copy link
Contributor

InMemoryPreferences will need to avoid using a goroutine here

@andydotxyz
Copy link
Member Author

InMemoryPreferences will need to avoid using a goroutine here

Good catch thanks. Fixed

@andydotxyz
Copy link
Member Author

OK, some platforms are now not detecting any races, so I have enabled it on the rest and working through what I hope is the last few!!!

@dweymouth
Copy link
Contributor

Use new RunFromGoroutine API here - https://github.com/fyne-io/fyne/blob/develop/app/settings_desktop.go#L48

@coveralls
Copy link

Coverage Status

coverage: 59.759% (+0.4%) from 59.329%
when pulling 7d5fb07 on andydotxyz:fix/racedetection
into 1bfc24c on fyne-io:develop.

@coveralls
Copy link

Coverage Status

coverage: 59.754% (+0.4%) from 59.329%
when pulling 367a6a6 on andydotxyz:fix/racedetection
into 1bfc24c on fyne-io:develop.

@coveralls
Copy link

Coverage Status

coverage: 59.764% (+0.4%) from 59.329%
when pulling 895953c on andydotxyz:fix/racedetection
into 1bfc24c on fyne-io:develop.

@coveralls
Copy link

coveralls commented Jan 9, 2025

Coverage Status

coverage: 59.228% (-0.1%) from 59.374%
when pulling 6369f2a on andydotxyz:fix/racedetection
into f2ba049 on fyne-io:develop.

@dweymouth
Copy link
Contributor

@Jacalz It seems we may need to remove or update the new pool_test. I think sync.Pool doesn't make a guarantee that an object released into the pool is immediately available for re-use, which is why it's failing occasionally here

@andydotxyz
Copy link
Member Author

@Jacalz It seems we may need to remove or update the new pool_test. I think sync.Pool doesn't make a guarantee that an object released into the pool is immediately available for re-use, which is why it's failing occasionally here

Good point, the contract includes this on Get:

// Get may choose to ignore the pool and treat it as empty.
// Callers should not assume any relation between values passed to Put and
// the values returned by Get.

So I have removed the Set/Get test - but the Get on empty and the replacement New tests should both be OK.

@andydotxyz
Copy link
Member Author

This sleep looks suspicous:

time.Sleep(time.Millisecond * 100) // writes are not always atomic. 10ms worked, 100 is safer.

Thanks - fixed. I left the delay as there was a bug reported about file write delay but then it joins back to main now

@andydotxyz andydotxyz self-assigned this Jan 10, 2025
@andydotxyz
Copy link
Member Author

PASS!!!

Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This is massively impressive. Well done! I left some notes and questions in-line :)

app/cloud_test.go Outdated Show resolved Hide resolved
app/preferences.go Show resolved Hide resolved
dialog/file.go Show resolved Hide resolved
internal/driver/mobile/canvas_test.go Outdated Show resolved Hide resolved
test/app.go Outdated Show resolved Hide resolved
widget/entry_cursor_anim.go Outdated Show resolved Hide resolved
@Jacalz
Copy link
Member

Jacalz commented Jan 11, 2025

I am getting a strange compile failure on Linux when building fyne_demo with -race now:

# fyne.io/fyne/v2/cmd/fyne_demo
/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/gcc -m64 -o $WORK/b001/exe/a.out -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=crosscall2 -Wl,--export-dynamic-symbol=glowDebugCallback_gl21 -Wl,--export-dynamic-symbol=goCharCB -Wl,--export-dynamic-symbol=goCharModsCB -Wl,--export-dynamic-symbol=goCursorEnterCB -Wl,--export-dynamic-symbol=goCursorPosCB -Wl,--export-dynamic-symbol=goDropCB -Wl,--export-dynamic-symbol=goErrorCB -Wl,--export-dynamic-symbol=goFramebufferSizeCB -Wl,--export-dynamic-symbol=goJoystickCB -Wl,--export-dynamic-symbol=goKeyCB -Wl,--export-dynamic-symbol=goMonitorCB -Wl,--export-dynamic-symbol=goMouseButtonCB -Wl,--export-dynamic-symbol=goScrollCB -Wl,--export-dynamic-symbol=goWindowCloseCB -Wl,--export-dynamic-symbol=goWindowContentScaleCB -Wl,--export-dynamic-symbol=goWindowFocusCB -Wl,--export-dynamic-symbol=goWindowIconifyCB -Wl,--export-dynamic-symbol=goWindowMaximizeCB -Wl,--export-dynamic-symbol=goWindowPosCB -Wl,--export-dynamic-symbol=goWindowRefreshCB -Wl,--export-dynamic-symbol=goWindowSizeCB -Wl,--compress-debug-sections=zlib /tmp/go-link-2655855783/go.o /tmp/go-link-2655855783/000000.o /tmp/go-link-2655855783/000001.o /tmp/go-link-2655855783/000002.o /tmp/go-link-2655855783/000003.o /tmp/go-link-2655855783/000004.o /tmp/go-link-2655855783/000005.o /tmp/go-link-2655855783/000006.o /tmp/go-link-2655855783/000007.o /tmp/go-link-2655855783/000008.o /tmp/go-link-2655855783/000009.o /tmp/go-link-2655855783/000010.o /tmp/go-link-2655855783/000011.o /tmp/go-link-2655855783/000012.o /tmp/go-link-2655855783/000013.o /tmp/go-link-2655855783/000014.o /tmp/go-link-2655855783/000015.o /tmp/go-link-2655855783/000016.o /tmp/go-link-2655855783/000017.o /tmp/go-link-2655855783/000018.o /tmp/go-link-2655855783/000019.o /tmp/go-link-2655855783/000020.o /tmp/go-link-2655855783/000021.o /tmp/go-link-2655855783/000022.o /tmp/go-link-2655855783/000023.o /tmp/go-link-2655855783/000024.o /tmp/go-link-2655855783/000025.o /tmp/go-link-2655855783/000026.o /tmp/go-link-2655855783/000027.o /tmp/go-link-2655855783/000028.o /tmp/go-link-2655855783/000029.o /tmp/go-link-2655855783/000030.o /tmp/go-link-2655855783/000031.o /tmp/go-link-2655855783/000032.o /tmp/go-link-2655855783/000033.o /tmp/go-link-2655855783/000034.o /tmp/go-link-2655855783/000035.o /tmp/go-link-2655855783/000036.o /tmp/go-link-2655855783/000037.o /tmp/go-link-2655855783/000038.o /tmp/go-link-2655855783/000039.o /tmp/go-link-2655855783/000040.o /tmp/go-link-2655855783/000041.o /tmp/go-link-2655855783/000042.o /tmp/go-link-2655855783/000043.o /tmp/go-link-2655855783/000044.o /tmp/go-link-2655855783/000045.o /tmp/go-link-2655855783/000046.o /tmp/go-link-2655855783/000047.o -O2 -g -O2 -g -lresolv -O2 -g -lGL -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -lm -lXinerama -ldl -lrt -O2 -g -lpthread -O2 -g -O2 -g -lGL -no-pie
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.(*mspan).setUserArenaChunkToFault':
go.go:(.text+0x7202): undefined reference to `__tsan_free'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.runfinq':
/usr/lib/golang/src/runtime/race.go:585:(.text+0x19614): undefined reference to `__tsan_finalizer_goroutine'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.(*sweepLocked).sweep':
/usr/lib/golang/src/runtime/race.go:461:(.text+0x27191): undefined reference to `__tsan_free'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.goexit1':
/usr/lib/golang/src/runtime/race.go:481:(.text+0x4399d): undefined reference to `__tsan_go_end'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.gfget':
/usr/lib/golang/src/runtime/race.go:456:(.text+0x45b39): undefined reference to `__tsan_malloc'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.(*p).init':
/usr/lib/golang/src/runtime/race.go:434:(.text+0x4665f): undefined reference to `__tsan_proc_create'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.(*p).destroy':
/usr/lib/golang/src/runtime/race.go:486:(.text+0x469d2): undefined reference to `__tsan_go_end'
/usr/bin/ld: /usr/lib/golang/src/runtime/race.go:440:(.text+0x46a29): undefined reference to `__tsan_proc_destroy'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.RaceDisable':
/usr/lib/golang/src/runtime/race.go:72:(.text+0x4b2c1): undefined reference to `__tsan_go_ignore_sync_begin'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.RaceEnable':
/usr/lib/golang/src/runtime/race.go:84:(.text+0x4b34d): undefined reference to `__tsan_go_ignore_sync_end'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.raceinit':
/usr/lib/golang/src/runtime/race.go:373:(.text+0x4b9af): undefined reference to `__tsan_init'
/usr/bin/ld: /usr/lib/golang/src/runtime/race.go:403:(.text+0x4ba1c): undefined reference to `__tsan_map_shadow'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racefini':
/usr/lib/golang/src/runtime/race.go:428:(.text+0x4bb1e): undefined reference to `__tsan_fini'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racemapshadow':
/usr/lib/golang/src/runtime/race.go:451:(.text+0x4bb9f): undefined reference to `__tsan_map_shadow'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racegostart':
/usr/lib/golang/src/runtime/race.go:475:(.text+0x4bc24): undefined reference to `__tsan_go_start'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.raceacquireg':
/usr/lib/golang/src/runtime/race.go:533:(.text+0x4be4a): undefined reference to `__tsan_acquire'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.raceacquirectx':
/usr/lib/golang/src/runtime/race.go:541:(.text+0x4beda): undefined reference to `__tsan_acquire'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racereleaseg':
/usr/lib/golang/src/runtime/race.go:554:(.text+0x4bf6a): undefined reference to `__tsan_release'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racereleaseacquireg':
/usr/lib/golang/src/runtime/race.go:567:(.text+0x4c00a): undefined reference to `__tsan_release_acquire'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racereleasemergeg':
/usr/lib/golang/src/runtime/race.go:580:(.text+0x4c0aa): undefined reference to `__tsan_release_merge'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.stackalloc':
/usr/lib/golang/src/runtime/race.go:456:(.text+0x53d56): undefined reference to `__tsan_malloc'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.mallocgc':
/usr/lib/golang/src/runtime/race.go:456:(.text+0x6c32c): undefined reference to `__tsan_malloc'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `racefuncenter':
/usr/lib/golang/src/runtime/race_amd64.s:182:(.text+0x7b0b0): undefined reference to `__tsan_func_enter'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `racecallatomic':
/usr/lib/golang/src/runtime/race_amd64.s:410:(.text+0x7b10e): undefined reference to `__tsan_go_ignore_sync_begin'
/usr/bin/ld: /usr/lib/golang/src/runtime/race_amd64.s:421:(.text+0x7b13e): undefined reference to `__tsan_go_ignore_sync_end'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.raceread':
/usr/lib/golang/src/runtime/race_amd64.s:51:(.text+0x7b1aa): undefined reference to `__tsan_read'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racereadpc.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:66:(.text+0x7b1f6): undefined reference to `__tsan_read_pc'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racewrite':
/usr/lib/golang/src/runtime/race_amd64.s:77:(.text+0x7b20a): undefined reference to `__tsan_write'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racewritepc.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:92:(.text+0x7b256): undefined reference to `__tsan_write_pc'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racereadrange':
/usr/lib/golang/src/runtime/race_amd64.s:104:(.text+0x7b26d): undefined reference to `__tsan_read_range'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racereadrangepc1.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:119:(.text+0x7b2b6): undefined reference to `__tsan_read_range'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racewriterange':
/usr/lib/golang/src/runtime/race_amd64.s:131:(.text+0x7b2cd): undefined reference to `__tsan_write_range'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racewriterangepc1.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:146:(.text+0x7b316): undefined reference to `__tsan_write_range'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `runtime.racefuncexit.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:193:(.text+0x7b34a): undefined reference to `__tsan_func_exit'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.StoreInt64.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:236:(.text+0x7b363): undefined reference to `__tsan_go_atomic64_store'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.SwapInt64.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:261:(.text+0x7b3a3): undefined reference to `__tsan_go_atomic64_exchange'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.AndInt32.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:309:(.text+0x7b3e3): undefined reference to `__tsan_go_atomic32_fetch_and'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.AndInt64.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:315:(.text+0x7b403): undefined reference to `__tsan_go_atomic64_fetch_and'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.OrInt32.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:334:(.text+0x7b463): undefined reference to `__tsan_go_atomic32_fetch_or'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.OrInt64.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:340:(.text+0x7b483): undefined reference to `__tsan_go_atomic64_fetch_or'
/usr/bin/ld: /tmp/go-link-2655855783/go.o: in function `sync/atomic.CompareAndSwapInt64.abi0':
/usr/lib/golang/src/runtime/race_amd64.s:366:(.text+0x7b4e3): undefined reference to `__tsan_go_atomic64_compare_exchange'
collect2: error: ld returned 1 exit status

Will clean my caches and restart the computer to see if it is some corrupt thing.

Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the same error on develop now for some reason. Anyway, this looks great 👍

@andydotxyz andydotxyz merged commit 2355f9d into fyne-io:develop Jan 11, 2025
12 checks passed
@andydotxyz andydotxyz deleted the fix/racedetection branch January 11, 2025 10:25
@andydotxyz andydotxyz mentioned this pull request Jan 11, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants